#include "Modify_Operation.h"


Modify_Operation::Modify_Operation(char *dn,int auth_type,char *passWord,char **optiuni,int nr_opt,vector<Atribut<char*>> atr_noi)
			:LDAP_Operation(dn,auth_type,optiuni,nr_opt)
{
	result=new char[1000];
	strcpy(result,"ldapmodify ");

	LDAPpassWord = new char[strlen(passWord)+1];
	strcpy(LDAPpassWord,passWord);

	this->atribute_noi = atr_noi;
}

Modify_Operation::~Modify_Operation(void)
{
}


LDAP_Operation* Modify_Operation::operate()
{

	switch(this->auth_type)
	{
	case 0: strcat(result,"-x ");
		break;
	case 1: strcat(result," ");
		break;
	default: printf("\nExceptie:");
		//exceptie;
	}

	for(int i=0;i<nr_opt;i++)
	{
		strcat(result,option[i]);
		strcat(result," ");
	}

	strcat(result,DN);

	strcat(result," -w ");
	strcat(result,LDAPpassWord);
	strcat(result," -f ");



	_LDIF ldif_modify(atribute_noi);
	char ldif[100];
	strcpy(ldif,ldif_modify.Da_LDIF());
	strcat(result,ldif);

	this->ldif_file = new char[strlen(ldif)+1];
	strcpy(ldif_file,ldif);

	LDAP_Operation *op=new Modify_Operation((*this));
	return op;

}
